[坑] It’s MIME type ('text/html') is not a supported stylesheet MIME type


Posted by david-christian on 2022-04-11

這是在寫mvc架構的 side project 引入 css 檔案時,發生的問題

瀏覽器 console 報錯訊息
Refused to apply style from 'http://localhost:3006/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

通常這都是無法正常引入 css 檔案所報的錯誤
解決方式是在 express middleware 設置讀取靜態文件的路徑
相關文件路徑:

middleware 設置
// app.js

引入
// index.ejs


#css #Express #html







Related Posts

[Note] React: React Router DOM v 6.3.X

[Note] React: React Router DOM v 6.3.X

【JS上課筆記】JavaScript 的非同步請求:AJAX、Fetch API

【JS上課筆記】JavaScript 的非同步請求:AJAX、Fetch API

traverse node 指定元素 (補)

traverse node 指定元素 (補)


Comments